﻿#include"stdafx.h"
#include "SQLexpression.h"


bool SqlEx::ForIndexCreate() {

	string db = CStringTostring(pSocket->cur_db);
	if (db == "") {
		pSocket->SendMSG("Please choose a database !");
		return 0;
	}
	string msg = "", tname = "",column="";
	regex reg1("(?<=create index ).+?(?= on)");
	regex reg2("(?<=on ).+?(?=\\()");
	regex reg3("(?<=\\().+?(?=\\)END)");
	string str;
	smatch sm;
	if (regex_search(Ex, sm, reg1)) {
		
	}
	else {
		pSocket->SendMSG("检查create index和on语句之间是否存在错误！！！");
		return false;
	}
	if (regex_search(Ex, sm, reg2)) {
		tname = sm.str();
	}
	else {
		pSocket->SendMSG("检查on语句之后是否存在错误！！！");
		return false;
	}
	if (regex_search(Ex, sm, reg3)) {
		column = sm.str();
	}
	else {
		pSocket->SendMSG("检查on语句之后是否存在错误！！！");
		return false;
	}
	serverDB->Index_Create(tname, db,column, msg);
	pSocket->SendMSG(msg);
	return true;
}